
/*This file produces results from main body of paper.  Executing this do file with the Stata dataset "microdata_cues.dta"
will reproduce Figure 2, Figure 3, and Figure 4 as well as Tables 1, 2, and 3 in the Appendix.  All figures in the
paper were constructed using R.  This file compiles coefficient estimates, standard errors, and other quantities of interest.
The R files used to create the figures is also included in the replication files. */  


clear
set more off
use "microdata_cues.dta"



/************************************************

**************REPUBLICAN MODELS*****************/

*Model 1: This is reported in paper: Model with no interactions.  Results are in upper left panel of Figure 2 and in Appendix Table 1 under
*the column heading "Model 1"*

ologit immig_self_whole libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC if pid==1 & race==1 [pw=v102], cluster(state) 

postfile temp_file b1 se1 b2 se2 b3 se3 b4 se4 b5 se5 b6 se6 b7 se7 b8 se8 b9 se9 b10 se10 b11 se11 b12 se12 b13 se13 b14 se14 b15 se15 b16 se16  using repvoterm1.dta, replace
foreach y of varlist immig_self_whole { 
  di _n as input  "."
    ologit immig_self_whole libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC if pid==1 & race==1 [pw=v102], cluster(state) 
	scalar b1=_b[libconN]
	scalar  se1=_se[libconN]
	scalar b2=_b[incomeI]
	scalar se2=_se[incomeI]
	scalar b3=_b[educN]
	scalar se3=_se[educN]
	scalar b4=_b[moraltrad]
	scalar se4=_se[moraltrad]
	scalar b5=_b[interestN]
	scalar se5=_se[interestN]
	scalar b6=_b[gender]
	scalar se6=_se[gender]
	scalar b7=_b[attendchurch]
	scalar se7=_se[attendchurch]
	scalar b8=_b[retrospect]
	scalar se8=_se[retrospect]
	scalar b9=_b[ageN]
	scalar se9=_se[ageN]
	scalar b10=_b[unemp]
	scalar se10=_se[unemp]
	scalar b11=_b[disthispanicpct_10_MC]
	scalar se11=_se[disthispanicpct_10_MC]
	scalar b12=_b[hd0010_MC]
	scalar se12=_se[hd0010_MC]
	scalar b13=_b[border]
	scalar se13=_se[border]
	scalar b14=_b[newdest1]
	scalar se14=_se[newdest1]
	scalar b15=_b[rep_priority_MC]
	scalar se15=_se[rep_priority_MC]
	scalar b16=_b[dem_priority_MC]
	scalar se16=_se[dem_priority_MC]
 post temp_file (b1) (se1) (b2) (se2) (b3) (se3) (b4) (se4) (b5) (se5) (b6) (se6) (b7) (se7) (b8) (se8) (b9) (se9) (b10) (se10) (b11) (se11) (b12) (se12) (b13) (se13) (b14) (se14) (b15) (se15) (b16) (se16)
}
postclose temp_file


****************

/*This code saves coefficient estimates to be read into R in order to create Figure 2*/

saveold microdata_R, replace 
clear

use repvoterm1.dta

expand=16

gen obs=_n

gen beta=b1 if obs==1
    replace beta=b2 if obs==2
    replace beta=b3 if obs==3
    replace beta=b4 if obs==4
    replace beta=b5 if obs==5
    replace beta=b6 if obs==6
    replace beta=b7 if obs==7
    replace beta=b8 if obs==8
    replace beta=b9 if obs==9
    replace beta=b10 if obs==10
    replace beta=b11 if obs==11
    replace beta=b12 if obs==12
    replace beta=b13 if obs==13
    replace beta=b14 if obs==14
    replace beta=b15 if obs==15
    replace beta=b16 if obs==16
      
gen se=se1 if obs==1
    replace se=se2 if obs==2
    replace se=se3 if obs==3
    replace se=se4 if obs==4
    replace se=se5 if obs==5
    replace se=se6 if obs==6
    replace se=se7 if obs==7    
    replace se=se8 if obs==8
    replace se=se9 if obs==9
    replace se=se10 if obs==10
    replace se=se11 if obs==11
    replace se=se12 if obs==12
	replace se=se13 if obs==13
	replace se=se14 if obs==14
	replace se=se15 if obs==15
	replace se=se16 if obs==16
    
    
generate str var3 = "Ideology" in 1
 replace var3 = "Income" in 2
 replace var3 = "Education" in 3
 replace var3 = "Moral Traditionalism" in 4
 replace var3 = "Interest in Politics" in 5
 replace var3 = "Female" in 6
 replace var3= "Attend Church" in 7
 replace var3= "Econ. Evaluation" in 8
 replace var3= "Age" in 9
 replace var3 = "District Unemployment" in 10
 replace var3 = "District Hispanic" in 11
 replace var3 = "Change in Dist. Hisp." in 12
 replace var3 = "Traditional Receiving" in 13
 replace var3 = "New Destination" in 14
 replace var3 = "Rep. Priority" in 15
 replace var3 = "Dem. Priority" in 16
  rename var3 label
  drop b1-b16 se1-se16
/*The following code creates an additional blank line in the input file
for purposes of plotting in R.*/
local new = _N + 1
        set obs `new'
        replace obs=0 if obs==. 
        sort obs
saveold repvoterm1, replace 

clear

use "microdata_cues.dta"



*Model 2: This is reported in paper: Model with new destination state interactions.  Results are in lower left panel of Figure 2 
*and in Appendix Table 1 under the column heading "Model 2"*  *

ologit immig_self_whole libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC nd_rp  if pid==1 & race==1 [pw=v102], cluster(state) 

postfile temp_file b1 se1 b2 se2 b3 se3 b4 se4 b5 se5 b6 se6 b7 se7 b8 se8 b9 se9 b10 se10 b11 se11 b12 se12 b13 se13 b14 se14 b15 se15 b16 se16 b17 se17   using repvoter.dta, replace
foreach y of varlist immig_self_whole { 
  di _n as input  
    ologit immig_self_whole libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC nd_rp  if pid==1 & race==1 [pw=v102], cluster(state) 
	scalar b1=_b[libconN]
	scalar  se1=_se[libconN]
	scalar b2=_b[incomeI]
	scalar se2=_se[incomeI]
	scalar b3=_b[educN]
	scalar se3=_se[educN]
	scalar b4=_b[moraltrad]
	scalar se4=_se[moraltrad]
	scalar b5=_b[interestN]
	scalar se5=_se[interestN]
	scalar b6=_b[gender]
	scalar se6=_se[gender]
	scalar b7=_b[attendchurch]
	scalar se7=_se[attendchurch]
	scalar b8=_b[retrospect]
	scalar se8=_se[retrospect]
	scalar b9=_b[ageN]
	scalar se9=_se[ageN]
	scalar b10=_b[unemp]
	scalar se10=_se[unemp]
	scalar b11=_b[disthispanicpct_10_MC]
	scalar se11=_se[disthispanicpct_10_MC]
	scalar b12=_b[hd0010_MC]
	scalar se12=_se[hd0010_MC]
	scalar b13=_b[border]
	scalar se13=_se[border]
	scalar b14=_b[newdest1]
	scalar se14=_se[newdest1]
	scalar b15=_b[rep_priority_MC]
	scalar se15=_se[rep_priority_MC]
	scalar b16=_b[dem_priority_MC]
	scalar se16=_se[dem_priority_MC]
	scalar b17=_b[nd_rp]
	scalar se17=_se[nd_rp]
 post temp_file (b1) (se1) (b2) (se2) (b3) (se3) (b4) (se4) (b5) (se5) (b6) (se6) (b7) (se7) (b8) (se8) (b9) (se9) (b10) (se10) (b11) (se11) (b12) (se12) (b13) (se13) (b14) (se14) (b15) (se15) (b16) (se16) (b17) (se17) 
}
postclose temp_file


****************
saveold microdata_R, replace 
clear

/*This code saves coefficient estimates to be read into R in order to create Figure 2*/

use repvoter.dta

expand=17

gen obs=_n

gen beta=b1 if obs==1
    replace beta=b2 if obs==2
    replace beta=b3 if obs==3
    replace beta=b4 if obs==4
    replace beta=b5 if obs==5
    replace beta=b6 if obs==6
    replace beta=b7 if obs==7
    replace beta=b8 if obs==8
    replace beta=b9 if obs==9
    replace beta=b10 if obs==10
    replace beta=b11 if obs==11
    replace beta=b12 if obs==12
    replace beta=b13 if obs==13
    replace beta=b14 if obs==14
    replace beta=b15 if obs==15
    replace beta=b16 if obs==16
	replace beta=b17 if obs==17
	
      
gen se=se1 if obs==1
    replace se=se2 if obs==2
    replace se=se3 if obs==3
    replace se=se4 if obs==4
    replace se=se5 if obs==5
    replace se=se6 if obs==6
    replace se=se7 if obs==7    
    replace se=se8 if obs==8
    replace se=se9 if obs==9
    replace se=se10 if obs==10
    replace se=se11 if obs==11
    replace se=se12 if obs==12
	replace se=se13 if obs==13
	replace se=se14 if obs==14
	replace se=se15 if obs==15
	replace se=se16 if obs==16
    replace se=se17 if obs==17
	
    
generate str var3 = "Ideology" in 1
 replace var3 = "Income" in 2
 replace var3 = "Education" in 3
 replace var3 = "Moral Traditionalism" in 4
 replace var3 = "Interest in Politics" in 5
 replace var3 = "Female" in 6
 replace var3= "Attend Church" in 7
 replace var3= "Econ. Evaluation" in 8
 replace var3= "Age" in 9
 replace var3 = "District Unemployment" in 10
 replace var3 = "District Hispanic" in 11
 replace var3 = "Change in Dist. Hisp." in 12
 replace var3 = "Traditional Receiving" in 13
 replace var3 = "New Destination" in 14
 replace var3 = "Rep. Priority" in 15
 replace var3 = "Dem. Priority" in 16
 replace var3 = "R. Pri. x New Dest." in 17
  rename var3 label
  drop b1-b17 se1-se17
/*The following code creates an additional blank line in the input file
for purposes of plotting in R.*/
local new = _N + 1
        set obs `new'
        replace obs=0 if obs==. 
        sort obs
saveold repvoter, replace 

clear

use "microdata_cues.dta"


*Interpretation of Republican Model: These give pr(Y=7). Results can be found in Figure 3, panels A and D*
*The estimates are saved and read into R in order to produce the plot*


clear

use "microdata_cues.dta"

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC  if pid==1 & race==1 [pw=v102], cluster(state) 

 margins, at(rep_priority_MC=(-1(.1)1) border=(0) newdest1=(1,0)) predict(outcome(7)), if e(sample)
    marginsplot


matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=7
gen newdest=1 if obs <= 21
replace newdest=0 if newdest==.
saveold Arep7, replace
drop if newdest==0
saveold Arep7nd, replace

clear
use Arep7
drop if newdest==1
saveold Arep7nnd, replace
clear

clear


use "microdata_cues.dta"


ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC  if pid==1 & race==1 [pw=v102], cluster(state) 

 margins, at(dem_priority_MC=(-1(.1)1) border=(0) newdest1=(0)) predict(outcome(7)), if e(sample)
    marginsplot


matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=7
gen newdest=1 if obs <= 21
replace newdest=0 if newdest==.
saveold Arep7D, replace


clear


use "microdata_cues.dta"


/*Interpretation of the Democratic Main Effect for Republican Identifiers*/


ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC  if pid==1 & race==1 [pw=v102], cluster(state) 

margins, at(dem_priority_MC=(-1(.1)1) border=(0) newdest1=(1,0)) predict(outcome(7)), if e(sample)
    marginsplot


matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=7
gen newdest=1 if obs <= 21
replace newdest=0 if newdest==.
saveold rep7Dmain, replace
drop if newdest==0
saveold rep7ndDmain, replace

clear
use rep7Dmain
drop if newdest==1
saveold rep7nndDmain, replace


clear


use "microdata_cues.dta"





/*************************************************/
/**************DEMOCRATIC MODELS******************/
/*************************************************/



*Model 1: This is reported in paper: Model with no interactions.  Results are in upper middle panel of Figure 2
*and in Appendix Table 2 under the column labeled "Model 1."*

ologit immig_self_whole libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC if pid==-1 & race==1 [pw=v102], cluster(state) 

postfile temp_file b1 se1 b2 se2 b3 se3 b4 se4 b5 se5 b6 se6 b7 se7 b8 se8 b9 se9 b10 se10 b11 se11 b12 se12 b13 se13 b14 se14 b15 se15 b16 se16  using demvoterm1.dta, replace
foreach y of varlist immig_self_whole { 
  di _n as input  "."
    ologit immig_self_whole libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC if pid==-1 & race==1 [pw=v102], cluster(state) 
	scalar b1=_b[libconN]
	scalar  se1=_se[libconN]
	scalar b2=_b[incomeI]
	scalar se2=_se[incomeI]
	scalar b3=_b[educN]
	scalar se3=_se[educN]
	scalar b4=_b[moraltrad]
	scalar se4=_se[moraltrad]
	scalar b5=_b[interestN]
	scalar se5=_se[interestN]
	scalar b6=_b[gender]
	scalar se6=_se[gender]
	scalar b7=_b[attendchurch]
	scalar se7=_se[attendchurch]
	scalar b8=_b[retrospect]
	scalar se8=_se[retrospect]
	scalar b9=_b[ageN]
	scalar se9=_se[ageN]
	scalar b10=_b[unemp]
	scalar se10=_se[unemp]
	scalar b11=_b[disthispanicpct_10_MC]
	scalar se11=_se[disthispanicpct_10_MC]
	scalar b12=_b[hd0010_MC]
	scalar se12=_se[hd0010_MC]
	scalar b13=_b[border]
	scalar se13=_se[border]
	scalar b14=_b[newdest1]
	scalar se14=_se[newdest1]
	scalar b15=_b[rep_priority_MC]
	scalar se15=_se[rep_priority_MC]
	scalar b16=_b[dem_priority_MC]
	scalar se16=_se[dem_priority_MC]
 post temp_file (b1) (se1) (b2) (se2) (b3) (se3) (b4) (se4) (b5) (se5) (b6) (se6) (b7) (se7) (b8) (se8) (b9) (se9) (b10) (se10) (b11) (se11) (b12) (se12) (b13) (se13) (b14) (se14) (b15) (se15) (b16) (se16)
}
postclose temp_file


****************
saveold microdata_R, replace 
clear


/*This code saves coefficient estimates to be read into R in order to create Figure 2*/


use demvoterm1.dta

expand=16

gen obs=_n

gen beta=b1 if obs==1
    replace beta=b2 if obs==2
    replace beta=b3 if obs==3
    replace beta=b4 if obs==4
    replace beta=b5 if obs==5
    replace beta=b6 if obs==6
    replace beta=b7 if obs==7
    replace beta=b8 if obs==8
    replace beta=b9 if obs==9
    replace beta=b10 if obs==10
    replace beta=b11 if obs==11
    replace beta=b12 if obs==12
    replace beta=b13 if obs==13
    replace beta=b14 if obs==14
    replace beta=b15 if obs==15
    replace beta=b16 if obs==16
      
gen se=se1 if obs==1
    replace se=se2 if obs==2
    replace se=se3 if obs==3
    replace se=se4 if obs==4
    replace se=se5 if obs==5
    replace se=se6 if obs==6
    replace se=se7 if obs==7    
    replace se=se8 if obs==8
    replace se=se9 if obs==9
    replace se=se10 if obs==10
    replace se=se11 if obs==11
    replace se=se12 if obs==12
	replace se=se13 if obs==13
	replace se=se14 if obs==14
	replace se=se15 if obs==15
	replace se=se16 if obs==16
    
    
generate str var3 = "Ideology" in 1
 replace var3 = "Income" in 2
 replace var3 = "Education" in 3
 replace var3 = "Moral Traditionalism" in 4
 replace var3 = "Interest in Politics" in 5
 replace var3 = "Female" in 6
 replace var3= "Attend Church" in 7
 replace var3= "Econ. Evaluation" in 8
 replace var3= "Age" in 9
 replace var3 = "District Unemployment" in 10
 replace var3 = "District Hispanic" in 11
 replace var3 = "Change in Dist. Hisp." in 12
 replace var3 = "Traditional Receiving" in 13
 replace var3 = "New Destination" in 14
 replace var3 = "Rep. Priority" in 15
 replace var3 = "Dem. Priority" in 16
  rename var3 label
  drop b1-b16 se1-se16
/*The following code creates an additional blank line in the input file
for purposes of plotting in R.*/
local new = _N + 1
        set obs `new'
        replace obs=0 if obs==. 
        sort obs
saveold demvoterm1, replace 

clear

use "microdata_cues.dta"



*Model 2: This is reported in paper: Model with new destination state interactions.  Results are in lower middle panel of Figure 2
*and in Appendix Table 2 under the column labeled "Model 2."*

ologit immig_self_whole libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC nd_rp  if pid==-1 & race==1 [pw=v102], cluster(state) 

postfile temp_file b1 se1 b2 se2 b3 se3 b4 se4 b5 se5 b6 se6 b7 se7 b8 se8 b9 se9 b10 se10 b11 se11 b12 se12 b13 se13 b14 se14 b15 se15 b16 se16 b17 se17   using demvoter.dta, replace
foreach y of varlist immig_self_whole { 
  di _n as input  
    ologit immig_self_whole libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC nd_rp  if pid==-1 & race==1 [pw=v102], cluster(state) 
	scalar b1=_b[libconN]
	scalar  se1=_se[libconN]
	scalar b2=_b[incomeI]
	scalar se2=_se[incomeI]
	scalar b3=_b[educN]
	scalar se3=_se[educN]
	scalar b4=_b[moraltrad]
	scalar se4=_se[moraltrad]
	scalar b5=_b[interestN]
	scalar se5=_se[interestN]
	scalar b6=_b[gender]
	scalar se6=_se[gender]
	scalar b7=_b[attendchurch]
	scalar se7=_se[attendchurch]
	scalar b8=_b[retrospect]
	scalar se8=_se[retrospect]
	scalar b9=_b[ageN]
	scalar se9=_se[ageN]
	scalar b10=_b[unemp]
	scalar se10=_se[unemp]
	scalar b11=_b[disthispanicpct_10_MC]
	scalar se11=_se[disthispanicpct_10_MC]
	scalar b12=_b[hd0010_MC]
	scalar se12=_se[hd0010_MC]
	scalar b13=_b[border]
	scalar se13=_se[border]
	scalar b14=_b[newdest1]
	scalar se14=_se[newdest1]
	scalar b15=_b[rep_priority_MC]
	scalar se15=_se[rep_priority_MC]
	scalar b16=_b[dem_priority_MC]
	scalar se16=_se[dem_priority_MC]
	scalar b17=_b[nd_rp]
	scalar se17=_se[nd_rp]
 post temp_file (b1) (se1) (b2) (se2) (b3) (se3) (b4) (se4) (b5) (se5) (b6) (se6) (b7) (se7) (b8) (se8) (b9) (se9) (b10) (se10) (b11) (se11) (b12) (se12) (b13) (se13) (b14) (se14) (b15) (se15) (b16) (se16) (b17) (se17) 
}
postclose temp_file


****************
saveold microdata_R, replace 
clear


/*This code saves coefficient estimates to be read into R in order to create Figure 2*/


use demvoter.dta

expand=17

gen obs=_n

gen beta=b1 if obs==1
    replace beta=b2 if obs==2
    replace beta=b3 if obs==3
    replace beta=b4 if obs==4
    replace beta=b5 if obs==5
    replace beta=b6 if obs==6
    replace beta=b7 if obs==7
    replace beta=b8 if obs==8
    replace beta=b9 if obs==9
    replace beta=b10 if obs==10
    replace beta=b11 if obs==11
    replace beta=b12 if obs==12
    replace beta=b13 if obs==13
    replace beta=b14 if obs==14
    replace beta=b15 if obs==15
    replace beta=b16 if obs==16
	replace beta=b17 if obs==17
	
      
gen se=se1 if obs==1
    replace se=se2 if obs==2
    replace se=se3 if obs==3
    replace se=se4 if obs==4
    replace se=se5 if obs==5
    replace se=se6 if obs==6
    replace se=se7 if obs==7    
    replace se=se8 if obs==8
    replace se=se9 if obs==9
    replace se=se10 if obs==10
    replace se=se11 if obs==11
    replace se=se12 if obs==12
	replace se=se13 if obs==13
	replace se=se14 if obs==14
	replace se=se15 if obs==15
	replace se=se16 if obs==16
    replace se=se17 if obs==17
	
    
generate str var3 = "Ideology" in 1
 replace var3 = "Income" in 2
 replace var3 = "Education" in 3
 replace var3 = "Moral Traditionalism" in 4
 replace var3 = "Interest in Politics" in 5
 replace var3 = "Female" in 6
 replace var3= "Attend Church" in 7
 replace var3= "Econ. Evaluation" in 8
 replace var3= "Age" in 9
 replace var3 = "District Unemployment" in 10
 replace var3 = "District Hispanic" in 11
 replace var3 = "Change in Dist. Hisp." in 12
 replace var3 = "Traditional Receiving" in 13
 replace var3 = "New Destination" in 14
 replace var3 = "Rep. Priority" in 15
 replace var3 = "Dem. Priority" in 16
 replace var3 = "R. Pri. x New Dest." in 17
  rename var3 label
  drop b1-b17 se1-se17
/*The following code creates an additional blank line in the input file
for purposes of plotting in R.*/
local new = _N + 1
        set obs `new'
        replace obs=0 if obs==. 
        sort obs
saveold demvoter, replace 

clear

use "microdata_cues.dta"


*Interpretation of Democrat Model: These give pr(Y=7). Results can be found in Figure 3, panels B and E*
*The estimates are saved and read into R in order to produce the plot*

clear


use "microdata_cues.dta"

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC  if pid==-1 & race==1 [pw=v102], cluster(state) 

 margins, at(rep_priority_MC=(-1(.1)1) border=(0) newdest1=(1,0)) predict(outcome(7)), if e(sample)
    marginsplot


matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=7
gen newdest=1 if obs <= 21
replace newdest=0 if newdest==.
saveold Adem7, replace
drop if newdest==0
saveold Adem7nd, replace

clear
use Adem7
drop if newdest==1
saveold Adem7nnd, replace
clear

clear


use "microdata_cues.dta"


ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC  if pid==-1 & race==1 [pw=v102], cluster(state) 

 margins, at(dem_priority_MC=(-1(.1)1) border=(0) newdest1=(0)) predict(outcome(7)), if e(sample)
    marginsplot


matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=7
gen newdest=1 if obs <= 21
replace newdest=0 if newdest==.
saveold Adem7D, replace


clear


use "microdata_cues.dta"






/*************************************************************************/
/***************************ALL RESPONDENTS*******************************/
/*************************************************************************/



*Model 1: This is reported in paper: Model with no interactions.  Results are in upper right panel of Figure 2
*and in the Appendix Table 3, under the column "Model 1."*

ologit immig_self_whole pid libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC if  race==1 [pw=v102], cluster(state) 

postfile temp_file b0 se0 b1 se1 b2 se2 b3 se3 b4 se4 b5 se5 b6 se6 b7 se7 b8 se8 b9 se9 b10 se10 b11 se11 b12 se12 b13 se13 b14 se14 b15 se15 b16 se16  using allvoterm1.dta, replace
foreach y of varlist immig_self_whole { 
  di _n as input  "."
    ologit immig_self_whole pid libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC if race==1 [pw=v102], cluster(state) 
	scalar b0=_b[pid]
	scalar se0=_se[pid]
	scalar b1=_b[libconN]
	scalar  se1=_se[libconN]
	scalar b2=_b[incomeI]
	scalar se2=_se[incomeI]
	scalar b3=_b[educN]
	scalar se3=_se[educN]
	scalar b4=_b[moraltrad]
	scalar se4=_se[moraltrad]
	scalar b5=_b[interestN]
	scalar se5=_se[interestN]
	scalar b6=_b[gender]
	scalar se6=_se[gender]
	scalar b7=_b[attendchurch]
	scalar se7=_se[attendchurch]
	scalar b8=_b[retrospect]
	scalar se8=_se[retrospect]
	scalar b9=_b[ageN]
	scalar se9=_se[ageN]
	scalar b10=_b[unemp]
	scalar se10=_se[unemp]
	scalar b11=_b[disthispanicpct_10_MC]
	scalar se11=_se[disthispanicpct_10_MC]
	scalar b12=_b[hd0010_MC]
	scalar se12=_se[hd0010_MC]
	scalar b13=_b[border]
	scalar se13=_se[border]
	scalar b14=_b[newdest1]
	scalar se14=_se[newdest1]
	scalar b15=_b[rep_priority_MC]
	scalar se15=_se[rep_priority_MC]
	scalar b16=_b[dem_priority_MC]
	scalar se16=_se[dem_priority_MC]
 post temp_file (b0) (se0) (b1) (se1) (b2) (se2) (b3) (se3) (b4) (se4) (b5) (se5) (b6) (se6) (b7) (se7) (b8) (se8) (b9) (se9) (b10) (se10) (b11) (se11) (b12) (se12) (b13) (se13) (b14) (se14) (b15) (se15) (b16) (se16)
}
postclose temp_file


****************
saveold microdata_R, replace 
clear


/*This code saves coefficient estimates to be read into R in order to create Figure 2*/


use allvoterm1.dta

expand=17

gen obs=_n

gen beta=b0 if obs==1
    replace beta=b1 if obs==2
    replace beta=b2 if obs==3
    replace beta=b3 if obs==4
    replace beta=b4 if obs==5
    replace beta=b5 if obs==6
    replace beta=b6 if obs==7
    replace beta=b7 if obs==8
    replace beta=b8 if obs==9
    replace beta=b9 if obs==10
    replace beta=b10 if obs==11
    replace beta=b11 if obs==12
    replace beta=b12 if obs==13
    replace beta=b13 if obs==14
    replace beta=b14 if obs==15
    replace beta=b15 if obs==16
    replace beta=b16 if obs==17
      
gen se=se0 if obs==1
    replace se=se1 if obs==2
    replace se=se2 if obs==3
    replace se=se3 if obs==4
    replace se=se4 if obs==5
    replace se=se5 if obs==6
    replace se=se6 if obs==7
    replace se=se7 if obs==8
    replace se=se8 if obs==9
    replace se=se9 if obs==10
    replace se=se10 if obs==11
    replace se=se11 if obs==12
    replace se=se12 if obs==13
    replace se=se13 if obs==14
    replace se=se14 if obs==15
    replace se=se15 if obs==16
    replace se=se16 if obs==17
    
    
generate str var3 = "PID" in 1
 replace var3 = "Ideology" in 2
 replace var3 = "Income" in 3
 replace var3 = "Education" in 4
 replace var3 = "Moral Traditionalism" in 5
 replace var3 = "Interest in Politics" in 6
 replace var3 = "Female" in 7
 replace var3= "Attend Church" in 8
 replace var3= "Econ. Evaluation" in 9
 replace var3= "Age" in 10
 replace var3 = "District Unemployment" in 11
 replace var3 = "District Hispanic" in 12
 replace var3 = "Change in Dist. Hisp." in 13
 replace var3 = "Traditional Receiving" in 14
 replace var3 = "New Destination" in 15
 replace var3 = "Rep. Priority" in 16
 replace var3 = "Dem. Priority" in 17
  rename var3 label
  drop b0-b16 se0-se16
/*The following code creates an additional blank line in the input file
for purposes of plotting in R.*/
local new = _N + 1
        set obs `new'
        replace obs=0 if obs==. 
        sort obs
saveold allvoterm1, replace 

clear

use "microdata_cues.dta"





*Model 2: This is reported in paper: Model with new destination state interactions.  Results are in lower right panel of Figure 2
*and in the Appendix Table 3, under the column "Model 2." *

ologit immig_self_whole pid libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC nd_rp  if  race==1 [pw=v102], cluster(state) 

postfile temp_file b0 se0 b1 se1 b2 se2 b3 se3 b4 se4 b5 se5 b6 se6 b7 se7 b8 se8 b9 se9 b10 se10 b11 se11 b12 se12 b13 se13 b14 se14 b15 se15 b16 se16 b17 se17   using allvoter.dta, replace
foreach y of varlist immig_self_whole { 
  di _n as input  
    ologit immig_self_whole pid libconN incomeI educN moraltrad interestN gender attendchurch retrospect ageN unemp disthispanicpct_10_MC hd0010_MC border newdest1 rep_priority_MC dem_priority_MC nd_rp  if  race==1 [pw=v102], cluster(state) 
	scalar b0=_b[pid]
	scalar se0=_se[pid]
	scalar b1=_b[libconN]
	scalar  se1=_se[libconN]
	scalar b2=_b[incomeI]
	scalar se2=_se[incomeI]
	scalar b3=_b[educN]
	scalar se3=_se[educN]
	scalar b4=_b[moraltrad]
	scalar se4=_se[moraltrad]
	scalar b5=_b[interestN]
	scalar se5=_se[interestN]
	scalar b6=_b[gender]
	scalar se6=_se[gender]
	scalar b7=_b[attendchurch]
	scalar se7=_se[attendchurch]
	scalar b8=_b[retrospect]
	scalar se8=_se[retrospect]
	scalar b9=_b[ageN]
	scalar se9=_se[ageN]
	scalar b10=_b[unemp]
	scalar se10=_se[unemp]
	scalar b11=_b[disthispanicpct_10_MC]
	scalar se11=_se[disthispanicpct_10_MC]
	scalar b12=_b[hd0010_MC]
	scalar se12=_se[hd0010_MC]
	scalar b13=_b[border]
	scalar se13=_se[border]
	scalar b14=_b[newdest1]
	scalar se14=_se[newdest1]
	scalar b15=_b[rep_priority_MC]
	scalar se15=_se[rep_priority_MC]
	scalar b16=_b[dem_priority_MC]
	scalar se16=_se[dem_priority_MC]
	scalar b17=_b[nd_rp]
	scalar se17=_se[nd_rp]
 post temp_file (b0) (se0) (b1) (se1) (b2) (se2) (b3) (se3) (b4) (se4) (b5) (se5) (b6) (se6) (b7) (se7) (b8) (se8) (b9) (se9) (b10) (se10) (b11) (se11) (b12) (se12) (b13) (se13) (b14) (se14) (b15) (se15) (b16) (se16) (b17) (se17) 
}
postclose temp_file


****************
saveold microdata_R, replace 
clear



/*This code saves coefficient estimates to be read into R in order to create Figure 2*/



use allvoter.dta

expand=18

gen obs=_n

gen beta=b0 if obs==1
    replace beta=b1 if obs==2
    replace beta=b2 if obs==3
    replace beta=b3 if obs==4
    replace beta=b4 if obs==5
    replace beta=b5 if obs==6
    replace beta=b6 if obs==7
    replace beta=b7 if obs==8
    replace beta=b8 if obs==9
    replace beta=b9 if obs==10
    replace beta=b10 if obs==11
    replace beta=b11 if obs==12
    replace beta=b12 if obs==13
    replace beta=b13 if obs==14
    replace beta=b14 if obs==15
    replace beta=b15 if obs==16
    replace beta=b16 if obs==17
	replace beta=b17 if obs==18
	
      
gen se=se0 if obs==1
    replace se=se1 if obs==2
    replace se=se2 if obs==3
    replace se=se3 if obs==4
    replace se=se4 if obs==5
    replace se=se5 if obs==6
    replace se=se6 if obs==7
    replace se=se7 if obs==8
    replace se=se8 if obs==9
    replace se=se9 if obs==10
    replace se=se10 if obs==11
    replace se=se11 if obs==12
    replace se=se12 if obs==13
    replace se=se13 if obs==14
    replace se=se14 if obs==15
    replace se=se15 if obs==16
    replace se=se16 if obs==17
    replace se=se17 if obs==18
    


    
generate str var3 = "PID" in 1
 replace var3 = "Ideology" in 2
 replace var3 = "Income" in 3
 replace var3 = "Education" in 4
 replace var3 = "Moral Traditionalism" in 5
 replace var3 = "Interest in Politics" in 6
 replace var3 = "Female" in 7
 replace var3= "Attend Church" in 8
 replace var3= "Econ. Evaluation" in 9
 replace var3= "Age" in 10
 replace var3 = "District Unemployment" in 11
 replace var3 = "District Hispanic" in 12
 replace var3 = "Change in Dist. Hisp." in 13
 replace var3 = "Traditional Receiving" in 14
 replace var3 = "New Destination" in 15
 replace var3 = "Rep. Priority" in 16
 replace var3 = "Dem. Priority" in 17
 replace var3 = "R. Pri. x New Dest." in 18
  rename var3 label
  drop b0-b17 se0-se17
/*The following code creates an additional blank line in the input file
for purposes of plotting in R.*/
local new = _N + 1
        set obs `new'
        replace obs=0 if obs==. 
        sort obs
saveold allvoter, replace 

clear

use "microdata_cues.dta"


*Interpretation of Full Model: These give pr(Y=7). Results can be found in Figure 3, panels C and E*

clear


use "microdata_cues.dta"

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC  if  race==1 [pw=v102], cluster(state) 

 margins, at(rep_priority_MC=(-1(.1)1) border=(0) newdest1=(1,0)) predict(outcome(7)), if e(sample)
    marginsplot


matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=7
gen newdest=1 if obs <= 21
replace newdest=0 if newdest==.
saveold Aall7, replace
drop if newdest==0
saveold Aall7nd, replace

clear
use Aall7
drop if newdest==1
saveold Aall7nnd, replace
clear

clear


use "microdata_cues.dta"


ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC  if race==1 [pw=v102], cluster(state) 

 margins, at(dem_priority_MC=(-1(.1)1) border=(0) newdest1=(0)) predict(outcome(7)), if e(sample)
    marginsplot


matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=7
gen newdest=1 if obs <= 21
replace newdest=0 if newdest==.
saveold Aall7D, replace



clear


use "microdata_cues.dta"



	
/***********Covariate Interpretation******************************************/	
 

/********************District Hispanic Population *******************/

/*This plot is found in Figure 4, Panel A*/


ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN c.unemp c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

/*Code to produce plots of district hispanic scale for outcome 7 and outcome 1*/
 margins,  at(disthispanicpct_10_MC=(-.1(.05).7) newdest1=(0) border=(0)) predict(outcome(7))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold disthisp7, replace

clear


use "microdata_cues.dta"


		

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1  [pw=v102], cluster(state) 

 margins,  at(disthispanicpct=(-.1(.05).7) newdest1=(0) border=(0)) predict(outcome(1))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold disthisp1, replace

clear

use "microdata_cues.dta"		 
		 
/*************************Change in District Hispanic********************************/

/**************This plot is found in Figure 4, Panel B*******************************/
		 
/*Code to produce plots of change in district hispanic scale in newdestination and nonnd states*/

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 


 margins,  at(hd0010_MC=(-.4(.05).4) newdest1=(0) border=(0)) predict(outcome(7))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold hispchange7, replace

clear

use "microdata_cues.dta"
		

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN  i.gender c.attendchurch c.retrospect c.ageN c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

 margins,  at(hd0010_MC=(-.4(.05).4) newdest1=(0) border=(0)) predict(outcome(1))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold hispchange1, replace

clear

use "microdata_cues.dta"		 
		 

		 
/********************Interpretation of Moral Traditionalism*******************/

/*This plot is found in Figure 4, Panel C*/

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

/*Code to produce plots of moral traditionalism scale in newdestination and nonnd states*/
 margins,  at(moraltrad=(0(.0625)1) newdest1=(0) border=(0)) predict(outcome(7))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold morals7, replace

clear

use "microdata_cues.dta"
		

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

 margins,  at(moraltrad=(0(.0625)1) newdest1=(0) border=(0)) predict(outcome(1))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold morals1, replace

clear

use "microdata_cues.dta"
	
	
/********************Interpretation of Church Attendance*******************/

/*This plot is found in Figure 4, Panel C*/

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

/*Code to produce plots of moral traditionalism scale in newdestination and nonnd states*/
 margins,  at(attendchurch=(0(.5)1) newdest1=(0) border=(0)) predict(outcome(7))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold church7, replace

clear

use "microdata_cues.dta"
		

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

 margins,  at(attendchurch=(0(.5)1) newdest1=(0) border=(0)) predict(outcome(1))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold church1, replace

clear

use "microdata_cues.dta"
		
		/********************Interpretation of Retro Econ*******************/

/*This plot is found in Figure 4, Panel C*/

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

/*Code to produce plots of moral traditionalism scale in newdestination and nonnd states*/
 margins,  at(retrospect=(0(.25)1) newdest1=(0) border=(0)) predict(outcome(7))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold retro7, replace

clear

use "microdata_cues.dta"
		

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

 margins,  at(retrospect=(0(.25)1) newdest1=(0) border=(0)) predict(outcome(1))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold retro1, replace

clear

use "microdata_cues.dta"
		
		
		
		
		 
/**************************Interpretation of District Unemployment****************************/

/*This plot is found in Figure 4, panel D*****************************************************/		 
/*Code to produce plots of change in district UNEMPLOYMENT */

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 


 margins,  at(unemp=(3(.5)13) newdest1=(0) border=(0)) predict(outcome(7))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold unemp7, replace

clear

use "microdata_cues.dta"
		

ologit immig_self_whole c.pid c.libconN c.incomeI c.educN c.moraltrad c.interestN i.gender c.attendchurch c.retrospect c.ageN  c.unemp c.disthispanicpct_10_MC c.hd0010_MC i.border i.newdest1 c.rep_priority_MC##i.newdest1 c.dem_priority_MC if race==1 [pw=v102], cluster(state) 

 margins,  at(unemp=(3(.5)13) newdest1=(0) border=(0)) predict(outcome(1))
 marginsplot

 
matrix pr=r(b)' 
matrix var=vecdiag(r(V))'
drop * 
svmat pr  
svmat var
g se=sqrt(var)
gen obs=_n
gen contrast=1
drop if pr1==0
saveold unemp1, replace

clear
